#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>

#define N 100

void  ysfSolution(int array[], int n, int m);

void main()
{
    int arr[N];
    int i;
    int n;
    int m;

    scanf("%d", &n);
    scanf("%d", &m);

    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }

    ysfSolution(arr, n, m);
}
void  ysfSolution(int array[], int n, int m)
{
    int i = 0;
    int count = 0;
    int k = 0;
    int p = n;

    for (int j = 0; j < n; j++)
        array[j] = 0;

    while (p > 1)
    {
        if (array[i % n] == 0)
            count++;
        i++;
        if (count == m)
        {
            k = (i - 1) % n;
            array[k] = 1;
            p--;
            printf("%2d", k + 1);
            count = 0;
        }
    }
}